package mianshi.regex;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author: 唐小尊
 * @email: 1171702529@qq.com
 * @cate: 2021/06/02 07:00
 */
public class Test {
    public static void main(String[] args) {
        String str = "(Jon,John)(Jon2,John2)(Jon3,John3)";
        String regex = "(\\w+,\\w+)";
        Pattern pat = Pattern.compile(regex);
        Matcher matcher = pat.matcher(str);
        String[] split = pat.split(str);
        for (String s : split) {
            System.out.println(s);
        }
        while (matcher.find()){
            System.out.println(matcher.group(0));
        }
    }
}
